﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Explorer.ascx.cs" Inherits="admin_webparts_Plug_ins_Files_Explorer" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="System.IO" %>
<style type="text/css">
    #addDir, #addFile {font-size:1.1em; font-weight: bold; }
    #addDir button, #addFile button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>
<div class="tip">
    <h1 style="left: 0px; position: relative;"><%=LanguageUtility.GetLanguageText("FILE_MANAGEMENT", Session)%></h1>
    <div style="display: block; width: 32px; height: 32px; float: right; position: relative; top: -27px;"><a title="<%=LanguageUtility.GetLanguageText("CLICK_RETURN", Session) %>" href="?type=<%=Request.QueryString["type"] %>"><img src="resources/images/Back.png" alt="" /></a></div>
    <table cellspacing="0" cellpadding="0" border="0" width="100%">
        <tr>
            <td align="left">
                <a class="path" href="?type=page&name=files&file=%2f"><%=NTTHAO.CommonWeb.WebGlobal.GetSite(System.Web.HttpContext.Current.Session).SiteID%></a> 
                <%
                    string[] parents = this._CurrentPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                    string path = "/";
                    for(int i = 0; i < parents.Length; i++)
                    {
                        string dir = parents[i];
                        path += dir + "/";
                        if (i < parents.Length - 1) {    
                %>
                /&nbsp;<a class="path" href="?type=page&name=files&file=<%=Server.UrlEncode(path) %>"><%=dir%></a>
                    <%} else {%>
                /&nbsp;<span class="path"><%=dir%></span>
                    <%} %>
                <%} %>
            </td>
        </tr>
        <tr>
            <td align="left">&nbsp;</td>
        </tr>
        <tr>
            <td align="left"><%=LanguageUtility.GetLanguageText("TOTAL", Session)%>:&nbsp;<%=this._TotalItem %>&nbsp;<%=LanguageUtility.GetLanguageText("ITEMS", Session)%></td>
        </tr>
    </table>
</div>
<%if(this._Message != string.Empty) { %>
<div class="tip tip_highlight">
    <%if (this._MessageType == 0) { %>
    <span class="b"><%=LanguageUtility.GetLanguageText("INFORMATION", Session)%>:&nbsp;</span><span><%=this._Message %></span>
    <%} else { %>
    <span class="b"><%=LanguageUtility.GetLanguageText("ERROR", Session)%>:&nbsp;</span><span class="red"><%=this._Message %></span>
    <%} %>
</div>
<%} %>
<p>
    <span id="addDir" class="yui-button yui-link-button yuibtn yuibtn-icon btnaddf"><span class="first-child"><a href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath) %>&action=createdir" tabindex="0"><%=LanguageUtility.GetLanguageText("CREATE_DIR", Session)%></a></span></span>
    <span id="addFile" class="yui-button yui-link-button yuibtn yuibtn-icon btnupload"><span class="first-child"><a href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath) %>&action=addfile" tabindex="0"><%=LanguageUtility.GetLanguageText("ADD_FILE", Session)%></a></span></span>
</p>
<script type="text/javascript">
    YAHOO.util.Event.onContentReady("addDir", function () {
        var oAddDir = new YAHOO.widget.Button("addDir");
        var oAddFile = new YAHOO.widget.Button("addFile");
    });
</script>
<table border="1" cellpadding="0" cellspacing="0" class="grid" id="tbGrid" style="margin-top: 10px;">
    <tr>
        <th width="10px">#</th>
        <th width="30px">&nbsp</th>
        <th><%=LanguageUtility.GetLanguageText("NAME", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("URL", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("IMAGE", Session)%></th>
        <th width="42px">&nbsp;</th>
    </tr>
    <%
        int index = 0;
        if (this._CurrentPath != "/")
        {
    %>
    <tr class="odd">
        <td align="center">&nbsp;</td>
        <td align="center"><a title="<%=LanguageUtility.GetLanguageText("CLICK_TO_PARENT", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this.ParentPath) %>"><img alt="" src="resources/images/file_pdir.gif" /></a></td>
        <td><a title="<%=LanguageUtility.GetLanguageText("CLICK_TO_PARENT", Session)%>" class="path" href="?type=page&name=files&file=<%=Server.UrlEncode(this.ParentPath) %>">..</a></td>
        <td>&nbsp;</td>
        <td align="center">&nbsp</td>
        <td align="center">&nbsp;</td>
    </tr>
    <%
        }
    %>
    <%
    for (int i = 0; i < this._DirectoryList.Length; i++)
    {
    %>
    <tr class="<%=((index + i)%2==1?"even":"odd") %>">
        <td align="center"><%=(index + i) + 1%></td>
        <td align="center"><a title="<%=LanguageUtility.GetLanguageText("CLICK_VIEW_INSIDE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>"><img alt="" src="resources/images/file_dir.gif" /></a></td>
        <td><a class="path" title="<%=LanguageUtility.GetLanguageText("CLICK_VIEW_INSIDE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>"><%=_DirectoryList[i]%></a></td>
        <td>&nbsp;</td>
        <td align="center">&nbsp</td>
        <td align="center">
            <ul class="icon" style="width: 140px;">
                <li><a title="<%=LanguageUtility.GetLanguageText("RENAME_FOLDER", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>&action=renamedir" class="icon rename">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("COPY", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>&action=copydir" class="icon copy">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>&action=movedir" class="icon movbn2">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _DirectoryList[i] + "/") %>&action=deletedir" class="icon deletebn">&nbsp</a></li>
            </ul>
        </td>
    </tr>
           <%
    }
    index += this._DirectoryList.Length;
    %>
    <%
    for (int i = 0; i < this._FileList.Length; i++)
    {
    %>
    <tr class="<%=((index + i)%2==1?"even":"odd") %>">
        <td align="center"><%=(index + i) + 1%></td>
        <td align="center"><a target="_blank" title="<%=LanguageUtility.GetLanguageText("CLICK_VIEW_FILE", Session)%>" href="<%=ROOT_PATH + this._CurrentPath.TrimStart('/') + _FileList[i] %>"><img alt="" src="resources/images/file.gif" /></a></td>
        <td><a class="path" target="_blank" title="<%=LanguageUtility.GetLanguageText("CLICK_VIEW_FILE", Session)%>" href="<%=ROOT_PATH + this._CurrentPath.TrimStart('/') + _FileList[i] %>"><%=_FileList[i]%></a></td>
        <td><%=ROOT_PATH.TrimStart('.') + this._CurrentPath.TrimStart('/') + _FileList[i]%></td>
        <td align="center"><%if (Constant.IMAGE_FILE_EXTENTIONS.Contains(Path.GetExtension(_FileList[i]).ToLower()))
          { %>
            <img class="thumb" src="<%=ROOT_PATH + this._CurrentPath.TrimStart('/') + _FileList[i] %>" />
        <%} %></td>
        <td align="left">
            <ul class="icon" style="width: 140px;">
                <li><a title="<%=LanguageUtility.GetLanguageText("RENAME_FILE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _FileList[i]) %>&action=renamefile" class="icon rename">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("COPY", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _FileList[i]) %>&action=copyfile" class="icon copy">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("MOVE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _FileList[i]) %>&action=movefile" class="icon movbn2">&nbsp</a></li>
                <li><a title="<%=LanguageUtility.GetLanguageText("DELETE", Session)%>" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _FileList[i]) %>&action=deletefile" class="icon deletebn">&nbsp</a></li><%
            if (".jpg".Equals(Path.GetExtension(_FileList[i]), StringComparison.OrdinalIgnoreCase)) { %>
                <li><a title="Resize image" href="?type=page&name=files&file=<%=Server.UrlEncode(this._CurrentPath + _FileList[i]) %>&action=resize" class="icon resizebtn">&nbsp</a></li>
                <%} %>
            </ul>
        </td>
    </tr>
           <%
    }
    %>
</table>